
  {FINAL.PA2}


  {Read Final Version of Game}

  PROCEDURE ReadFinalVersion;

  VAR
    i : Integer;
    st : words;
    Read_Text_file : Text;
    RoomFile : FILE OF rooms;
    NounFile : FILE OF nouns;
    CreatureFile : FILE OF creatures;
    CommandFile : FILE OF Command;
  BEGIN                           {ReadFinalVersion}

    {first -- some general initialization -- normally in Initialize_Part_1}
    Word_Chars := ['0'..'9', 'A'..'Z', 'a'..'z', '-', '_'];
    player_dead := False;
    Current_Life := 1;
    Num_turns := 0;
    game_won := False;
    game_end := False;
    Num_saves := 0; num_restores := 0;
    verbose := True;              {default is to describe every room}
    FOR i := 0 TO MaxCounter DO counter[i] := 0; {zero counters}
    FOR i := 0 TO MaxVariable DO Variable[i] := 0; {zero variable}
    FOR i := 0 TO MaxFlag DO Flag[i] := False; {make all flags FALSE}

    Subject_IT[Thing] := 'it';    {Subject pronouns for Creature = Thing}
    Cap_Subject_IT[Thing] := 'It';
    Object_IT[Thing] := 'it';
    Snarls[Thing] := 'snarls';    {verbs for Creature = Thing}
    Screeches[Thing] := 'screeches';
    Subject_IT[Man] := 'he';      {Subject pronouns for Creature = Man}
    Cap_Subject_IT[Man] := 'He';
    Object_IT[Man] := 'him';
    Snarls[Man] := 'scowls';      {verbs for Creature = Man}
    Screeches[Man] := 'screams';
    Subject_IT[Woman] := 'she';   {Subject pronouns for Creature = Woman}
    Cap_Subject_IT[Woman] := 'She';
    Object_IT[Woman] := 'her';
    Snarls[Woman] := 'scowls';    {verbs for Creature = Woman}
    Screeches[Woman] := 'screams';
    IsOrAre[Singular] := 'is';
    IsOrAre[Plural] := 'are';
    ItOrThem[Singular] := 'it';
    ItOrThem[Plural] := 'them';


    {first read the text file with general data}
    Assign(Read_Text_file, Adventure_Name+'.DA1');
    Reset(Read_Text_file);
    ReadLn(Read_Text_file, Starting_room);
    Current_room := Starting_room; {start off here}
    ReadLn(Read_Text_file, Treasure_Room);
    ReadLn(Read_Text_file, Resurrection_Room);
    ReadLn(Read_Text_file, Max_Lives);
    ReadLn(Read_Text_file, Maximum_Score);
    ReadLn(Read_Text_file, MaxRoom);
    ReadLn(Read_Text_file, MaxNoun);
    ReadLn(Read_Text_file, MaxCreature);
    ReadLn(Read_Text_file, Last_CMD);
    ReadLn(Read_Text_file, Items_Being_Carried);
    ReadLn(Read_Text_file, Items_Being_Worn);
    ReadLn(Read_Text_file, Intro_Ptr.start);
    ReadLn(Read_Text_file, Intro_Ptr.len);

    FOR i := 1 TO MaxQuestion DO
      BEGIN
        ReadLn(Read_Text_file, Question[i]);
        ReadLn(Read_Text_file, Answer[i]);
      END;

    ReadLn(Read_Text_file, st);
    Any_Special_Cmds := (st = 'TRUE');
    IF Any_Special_Cmds THEN FOR i := 0 TO Last_Creature DO
      BEGIN
        ReadLn(Read_Text_file, StartingIndex[i]);
        ReadLn(Read_Text_file, EndingIndex[i]);
      END;

    FOR i := 0 TO Num_Verbs DO ReadLn(Read_Text_file, SYN[i]); {verb synonyms}

    FOR i := First_Message TO Last_Message DO
      BEGIN                       {Read pointers to description file}
        ReadLn(Read_Text_file, Message_Ptr[i].start);
        ReadLn(Read_Text_file, Message_Ptr[i].len);
      END;

    FOR i := First_Room TO MaxRoom DO
      BEGIN
        ReadLn(Read_Text_file, Room_Ptr[i].start);
        ReadLn(Read_Text_file, Room_Ptr[i].len);
        ReadLn(Read_Text_file, Help_Ptr[i].start);
        ReadLn(Read_Text_file, Help_Ptr[i].len);
        ReadLn(Read_Text_file, Special_Ptr[i].start);
        ReadLn(Read_Text_file, Special_Ptr[i].len);
      END;

    FOR i := First_noun TO MaxNoun DO
      BEGIN
        ReadLn(Read_Text_file, Noun_Ptr[i].start);
        ReadLn(Read_Text_file, Noun_Ptr[i].len);
        ReadLn(Read_Text_file, Push_Ptr[i].start);
        ReadLn(Read_Text_file, Push_Ptr[i].len);
        ReadLn(Read_Text_file, Pull_Ptr[i].start);
        ReadLn(Read_Text_file, Pull_Ptr[i].len);
        ReadLn(Read_Text_file, Text_Ptr[i].start);
        ReadLn(Read_Text_file, Text_Ptr[i].len);
        ReadLn(Read_Text_file, Turn_Ptr[i].start);
        ReadLn(Read_Text_file, Turn_Ptr[i].len);
        ReadLn(Read_Text_file, Play_Ptr[i].start);
        ReadLn(Read_Text_file, Play_Ptr[i].len);
      END;

    IF MaxCreature > 0 THEN FOR i := First_creature TO MaxCreature DO
      BEGIN
        ReadLn(Read_Text_file, Creature_Ptr[i].start);
        ReadLn(Read_Text_file, Creature_Ptr[i].len);
      END;

    Close(Read_Text_file);

    {next read the ROOM file}
    Assign(RoomFile, Adventure_Name+'.DA2');
    Reset(RoomFile);
    FOR i := First_Room TO MaxRoom DO
      BEGIN
        New(Room[i]);
        Read(RoomFile, Room[i]^);
      END;
    Close(RoomFile);

    {next read the NOUN file}
    Assign(NounFile, Adventure_Name+'.DA3');
    Reset(NounFile);
    FOR i := First_noun TO MaxNoun DO
      BEGIN
        New(N[i]);
        Read(NounFile, N[i]^);
      END;
    Close(NounFile);

    {next read the CREATURE file}
    IF MaxCreature > 0 THEN
      BEGIN
        Assign(CreatureFile, Adventure_Name+'.DA4');
        Reset(CreatureFile);
        FOR i := First_creature TO MaxCreature DO
          BEGIN
            New(M[i]);
            Read(CreatureFile, M[i]^);
          END;
        Close(CreatureFile);
      END;

    {next read the Special Command file -- if used}
    IF Any_Special_Cmds THEN
      BEGIN
        Assign(CommandFile, Adventure_Name+'.DA5');
        Reset(CommandFile);
        FOR i := 1 TO Last_CMD DO
          BEGIN
            New(SpecialCMD[i]);
            Read(CommandFile, SpecialCMD[i]^);
          END;
        Close(CommandFile);
      END;

    Assign(descr_file, descr_file_name);
    Reset(descr_file);
    IF Intro_Ptr.start >= 1 THEN
      BEGIN
        CLRSCR;
        Describe_It('INTRO', 0);
      END;
  END;                            {ReadFinalVersion}

